<?php

class Manage
{	
    private	$db_host;
	private	$db_name;
	private $db_user;
	private $db_password;
	private $connection;
    
    function __construct ()
	{		
		$this -> db_host = 'localhost';
		$this -> db_name = 'SEC_DB';
		$this -> db_user = 'postgres';
		$this -> db_password = 'breck';
	}
    
    public function obtenerUsuarios()
    {
        $this -> connect();
        $query = "SELECT * FROM USER_SEC";
        $result = pg_query($this ->connection, $query) or die('Query failed: ' . pg_last_error());
        
        while ($row = pg_fetch_array($result))
        {
            print_r ($row);
            echo "<br />";
            echo "<br />";
        }
        $this -> disconnect();
        
    }

	private function connect()
	{
		$this -> connection = pg_connect("host='$this->db_host' dbname='$this->db_name' user='$this->db_user' password='$this->db_password'")
			or die('Could not connect: ' . pg_last_error());
        if($this -> connection)
		{
			return true;
		}
		else
			return false;
	}
    
	private function disconnect()
	{
		pg_close($this -> connection);
	}
}
?>